<template>
  <div class="app-container">
    <el-form :inline="true" :model="pageInfo" class="demo-form-inline">
      <el-form-item label="用户名&用户操作">
        <el-input v-model="pageInfo.username" placeholder="用户名&用户操作"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>
    <template>
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="title"
          label="id"
          width="180">
        </el-table-column>
        <el-table-column
          prop="username"
          label="用户名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="operation"
          label="用户操作"
          width="180">
        </el-table-column>
        <el-table-column
          prop="methond"
          label="请求方法"
          width="180">
        </el-table-column>
        <el-table-column
          prop="params"
          label="请求参数"
          width="180">
        </el-table-column>
        <el-table-column
          prop="time"
          label="执行时长(毫秒)"
          width="180">
        </el-table-column>
        <el-table-column
          prop="ip"
          label="IP地址"
          width="180">
        </el-table-column>
        <el-table-column
          prop="createDate"
          label="创建时间"
          width="180">
        </el-table-column>
      </el-table>
    </template>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageInfo.pageNum"
      :page-sizes="[10, 30, 50, 70]"
      :page-size="pageInfo.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  created() {
    this.list()
  },
  data() {
    return {
      tableData: [],
      pageInfo:{
        pageNum:null,
        pageSize:null,
        username:null,

      },
      total:null,
      form:{
        id:'',
        username:"",
        operation:"",
        method:"",
        params:"",
        time:"",
        ip:"",
        createDate:"",

      }
    }
  },
  methods: {
    list() {
      this.axios.get("http://localhost:80/api/sys/wish/sys-log/selects", {params: this.pageInfo}).then((response) => {
        console.log(response.data)
        this.tableData = response.data.obj.list
        this.pageInfo.pageNum = response.data.obj.pageNum
        this.pageInfo.pageSize = response.data.obj.pageSize
        this.total = response.data.obj.total
      })
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.pageInfo.pageSize = val
      this.list()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
      this.pageInfo.pageNum = val
      this.list()
    },
    onSubmit() {
      console.log('submit!')
      this.list()
    }
  }
}
</script>

